package com.scarecrow.olga.test {
	
	import com.scarecrow.olga.input.event.KeyboardInputEvent;
	import com.scarecrow.olga.input.InputManager;
	
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author Santiago.J.Elizalde
	 */
	public class InputTest extends Sprite {
		
		private var pepeManager:InputManager;
		
		public function InputTest():void {
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			pepeManager = new InputManager();
			pepeManager.stage = this.stage;
			pepeManager.messageBroadcaster.addEventListener(KeyboardInputEvent.KEY_UP, onKUp);
			pepeManager.messageBroadcaster.addEventListener(MouseEvent.MOUSE_DOWN, onMDown);
			pepeManager.messageBroadcaster.addEventListener(MouseEvent.MOUSE_UP, onMUp);
		}
		
		private function onMUp(e:MouseEvent):void {
			trace("[MOUSE] right click released.")
		}
		
		private function onMDown(e:MouseEvent):void {
			trace("[MOUSE] right click pressed.")
		}
		
		private function onKUp(e:KeyboardInputEvent):void {
			trace("[KEYBOARD] you have pressed the key '" + e.pressedKey + "' for " + e.holdTime + " seconds (" + e.repeatCount + " times repeated)");
		}
	}

}